package com.drink.yan.web.rest;

import com.drink.yan.domain.YanOrderDo;
import com.drink.yan.intf.entity.YanOrder;
import com.drink.yan.intf.vo.OrderVo;
import com.drink.yan.svc.service.YanOrderService;
import com.drink.yan.web.rest.req.cmd.ApplyOrderCmd;
import com.drink.yan.web.rest.req.cmd.OrderOperateCmd;
import com.drink.yan.web.rest.req.qry.PageOrderQry;
import com.meta.framework.common.core.controller.BaseController;
import com.meta.framework.common.core.page.TableResponseVo;
import com.meta.framework.core.ResponseVo;
import io.lettuce.core.dynamic.annotation.Param;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * java类简单作用描述
 *
 * @Title:
 * @Package: com.drink.yan.web.rest.app.
 * @Author: M.simple
 * @Remark: The modified content
 * @CreateDate: 2023/11/23 14:58
 * @Version: v2.0
 */
@RestController
@RequestMapping("/order")
public class OrderRest extends BaseController {

    @Resource
    private YanOrderService yanOrderService;

    @ApiOperation(value = "订单列表", notes = "订单列表", tags = {"PC"})
    @GetMapping("/page")
    public TableResponseVo<List<OrderVo>> pageOrder(PageOrderQry qry){

        startPage();
        List<OrderVo> list = yanOrderService.listOrder(qry);
        return getResponseVoTable(list);
    }

    @ApiOperation(value = "订单详情", notes = "订单详情", tags = {"PC"})
    @GetMapping("/detail/{orderNo}")
    public ResponseVo<OrderVo> detail(@PathVariable("orderNo") Long orderNo){

        OrderVo orderVo = yanOrderService.getOrderDetail(orderNo);
        return ResponseVo.success(orderVo);
    }

    @ApiOperation(value = "下单接口", notes = "下单接口", tags = {"学生小程序"})
    @PostMapping("/apply")
    public ResponseVo<YanOrderDo> applyOrder(@RequestBody ApplyOrderCmd cmd){

        YanOrder yanOrder = yanOrderService.applyOrder(cmd);
        return ResponseVo.success(yanOrder);
    }

    @ApiOperation(value = "支付", notes = "支付", tags = {"PC"})
    @PostMapping("/pay")
    public ResponseVo<YanOrderDo> pay(@RequestBody OrderOperateCmd cmd){

        YanOrder yanOrder = yanOrderService.payOrder(cmd);
        return ResponseVo.success(yanOrder);
    }

    @ApiOperation(value = "发货接口", notes = "发货接口", tags = {"PC"})
    @PostMapping("/deliver")
    public ResponseVo<YanOrderDo> deliver(@RequestBody OrderOperateCmd cmd){

        YanOrder yanOrder = yanOrderService.deliverOrder(cmd);
        return ResponseVo.success(yanOrder);
    }

    @ApiOperation(value = "收货", notes = "收货", tags = {"PC"})
    @PostMapping("/receive")
    public ResponseVo<YanOrderDo> receive(@RequestBody OrderOperateCmd cmd){

        YanOrder yanOrder = yanOrderService.receiveOrder(cmd);
        return ResponseVo.success(yanOrder);
    }

    @ApiOperation(value = "完成", notes = "完成", tags = {"PC"})
    @PostMapping("/complete")
    public ResponseVo<YanOrderDo> complete(@RequestBody OrderOperateCmd cmd){

        YanOrder yanOrder = yanOrderService.completeOrder(cmd);
        return ResponseVo.success(yanOrder);
    }

    @ApiOperation(value = "取消", notes = "取消", tags = {"PC"})
    @PostMapping("/cancel")
    public ResponseVo<YanOrderDo> cancel(@RequestBody OrderOperateCmd cmd){

        YanOrder yanOrder = yanOrderService.cancelOrder(cmd);
        return ResponseVo.success(yanOrder);
    }
}
